<?php
    include('./library/connsql.php');
    
    $username = $_REQUEST['username'];
    $password = $_REQUEST['password'];

    $sql = "select * from users where (username = '$username' or email = '$username' or phone = '$username' ) and password = '$password' ";

    $res = $mysqli->query($sql);

    $mysqli->close();

    if($res->num_rows>0){
        // 账号密码正确

        // 登录成功，获得用户名
        $row = $res->fetch_assoc();
        setcookie('username',$row['username'],time()+3600*24,'/');
        setcookie('isLogined','true',time()+3600*24,'/');

        echo '1';
        // echo "<script>location.href'../src/html/index.html'</script>";
    }else{
        // 账号密码错误
        echo '0';
    }
?>